package com.efast.dmom.mgmt.controller.les;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.efast.cafe.framework.bean.ResultBean;
import com.efast.dmom.mgmt.bean.les.HomeTwDocAsnDetailsBean;
import com.efast.dmom.mgmt.bean.les.HomeTwDocOrderDetailsBean;
import com.efast.dmom.mgmt.bean.les.HomeTwInvSkuLoctlBean;
import com.efast.dmom.mgmt.bean.les.WarehousingTaskVolumeResultBean;
import com.efast.dmom.mgmt.service.les.HomePageDataService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
import java.util.Map;

/**
 * @author chlp
 */
@Controller
@RequestMapping(value = "/home")
@Api(description = "首页数据显示")
public class HomePageDataController {

	private final HomePageDataService homePageDataService;

	@Autowired
	public HomePageDataController(HomePageDataService homePageDataService) {
		this.homePageDataService = homePageDataService;
	}

	/**
	 * 入库零件Top数量（按三月统计总量）
	 *
	 * @param requestData
	 *            {"week":5}
	 * @return ResultBean
	 */
	@ApiOperation(value = "入库零件Top数量（按三月统计总量）", notes = "请求数据结构:{\"month\":3}")
	@RequestMapping(value = "/warehousing", method = RequestMethod.POST)
	public @ResponseBody ResultBean warehousing(@RequestBody Map<String, Object> requestData) {
		ResultBean result = new ResultBean(true, "'");
		List<HomeTwDocAsnDetailsBean> homeTwInvSkuLoctlBeanList = homePageDataService.queryRecentlyWarehousingData(
				(Integer) requestData.get("month"));
		result.setObject(homeTwInvSkuLoctlBeanList);
		return result;
	}

	/**
	 * 出库零件Top数量（按三月统计总量）
	 *
	 * @param requestData
	 *            {"week":5}
	 * @return ResultBean
	 */
	@ApiOperation(value = "出库零件Top数量（按三月统计总量）", notes = "请求数据结构:{\"month\":3}")
	@RequestMapping(value = "/outgoing", method = RequestMethod.POST)
	public @ResponseBody ResultBean outgoing(@RequestBody Map<String, Object> requestData) {
		ResultBean result = new ResultBean(true, "'");
		List<HomeTwDocOrderDetailsBean> homeTwDocAsnDetailsBeans = homePageDataService.queryRecentlyOutgoingData(
				(Integer) requestData.get("month"));
		result.setObject(homeTwDocAsnDetailsBeans);
		return result;
	}

	/**
	 * 库存监控:查询库存表零件的前10个总数排名
	 * 
	 * @param requestData
	 *            不需要传递请求参数
	 * @return ResultBean
	 */
	@ApiOperation(value = "库存监控", notes = "不需要传递请求参数")
	@RequestMapping(value = "/inventoryControl", method = RequestMethod.POST)
	public @ResponseBody ResultBean inventoryControl(@RequestBody Map<String, Object> requestData) {
		ResultBean result = new ResultBean(true, "'");
		List<HomeTwInvSkuLoctlBean> homeTwDocAsnDetailsBeans = homePageDataService.inventoryControl();
		result.setObject(homeTwDocAsnDetailsBeans);
		return result;
	}

	@ApiOperation(value = "仓储任务量（按月度统计全年）（收货、质检、上架、拣货、补货）-----任务量趋势", notes = "仓储任务量")
	@RequestMapping(value = "/warehousingTask", method = RequestMethod.POST)
	public @ResponseBody ResultBean warehousingTask(@RequestBody Map<String, Object> requestData) {
		ResultBean result = new ResultBean(true, "'");
		List<WarehousingTaskVolumeResultBean> resultBeans = homePageDataService.warehousingTaskVolume();
		result.setObject(resultBeans);
		return result;
	}
}
